package chapter18;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/3/25 12:54
 */
public class IntBufferDemo {
    private static final int BSIZE = 1024;

    public static void main(String[] args) {
        ByteBuffer bb = ByteBuffer.allocate(BSIZE);
        IntBuffer intBuffer = bb.asIntBuffer();
        intBuffer.put(new int[]{11, 32, 12, 34, 14, 56, 77});
        System.out.println(intBuffer.get(3));

        intBuffer.flip();
        while (intBuffer.hasRemaining()) {
            int i = intBuffer.get();
            System.out.println(i);
        }
    }
}
